#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int n;
int main()
{
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		ans += a[i];
	}
	int ma = 0;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += a[i];
		ma = max(sum, ma);
		if (sum < 0)sum = 0;
	}
	ma = max(sum, ma);
	cout << 2 * ma - ans << endl;
	return 0;
}